const key = '0726766bbf819ce6b3d7288a140a69b5'; //高德地图 key

/**
 * @description 保留当前页面，跳转到应用内的某个页面
 */
function navigateTo(
	url,
	animationType = 'zoom-fade-out',
	animationDuration = 300,
	success = function(res) {
		console.log(res)
	},
	fail = function(res) {
		console.log(res)
	},
	complete = function(err) {
		console.log(err)
	}
) {
	console.log(url);
	uni.navigateTo({
		url: url,
		animationType,
		animationDuration,
		success,
		fail,
		complete
	});
}

/**
 * @description 计算两经纬度点间距离
 * @return {Number}
 */
function getDistance(la1, lo1, la2, lo2) {
	var La1 = la1 * Math.PI / 180.0;
	var La2 = la2 * Math.PI / 180.0;
	var La3 = La1 - La2;
	var Lb3 = lo1 * Math.PI / 180.0 - lo2 * Math.PI / 180.0;
	var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(La3 / 2), 2) + Math.cos(La1) * Math.cos(La2) * Math.pow(Math.sin(Lb3 / 2), 2)));
	s = s * 6378.137;//地球半径
	s = Math.round(s * 10000) / 10000;
	return s
}

export default {
	navigateTo,
	getDistance
}
